home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / SDREGU.RUL < prev    next >
Encoding:
Text File  |  1997-11-20  |  7.0 KB  |  174 lines

  1.  
  2.  /*=======================================================================*/
  3.  /*                                                                       */
  4.  /*           (c) InstallShield Software Corporation (1996-1997)          */
  5.  /*            (c)  InstallShield Corporation  (1990-1996)                */
  6.  /*                       Schaumburg, Illinois 60173                      */
  7.  /*                          All Rights Reserved                          */
  8.  /*                           InstallShield (R)                           */
  9.  /*                                                                       */
  10.  /*   File    : sdregu.rul                                                */
  11.  /*                                                                       */
  12.  /*   Purpose : This file contains the code for the SdRegisterUser        */
  13.  /*             script dialog function.                                   */
  14.  /*                                                                       */
  15.  /*=======================================================================*/ 
  16.  
  17.  /*------------------------------------------------------------------------*/
  18.  /*                                                                        */
  19.  /*   Function: SdRegisterUser                                             */
  20.  /*                                                                        */
  21.  /*   Descrip:  This dialog will ask user for registration infomation.     */
  22.  /*                                                                        */
  23.  /*   Misc:                                                                */
  24.  /*                                                                        */
  25.  /*------------------------------------------------------------------------*/
  26. function SdRegisterUser( szTitle, szMsg, svName, svCompany )
  27.           STRING  szDlg, szTemp;
  28.           NUMBER  nId, nMessage, nTemp;
  29.           HWND    hwndDlg;
  30.           BOOL    bDone;
  31.         begin
  32.  
  33.            szDlg     = SD_DLG_REGISTERUSER;
  34.            nSdDialog = SD_NDLG_REGISTERUSER;
  35.  
  36.           // record data produced by this dialog
  37.           if (MODE=SILENTMODE) then
  38.             SdMakeName( szAppKey, szDlg, szTitle, nSdRegisterUser );
  39.             SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
  40.             if ((nId != BACK) && (nId != CANCEL)) then
  41.                SilentReadData( szAppKey, "szName", DATA_STRING, svName, nTemp );
  42.                SilentReadData( szAppKey, "szCompany", DATA_STRING, svCompany, nTemp );
  43.             endif;
  44.  
  45.             return nId;
  46.           endif;
  47.  
  48.            // ensure general initialization is complete
  49.            if (!bSdInit) then
  50.               SdInit();
  51.            endif;
  52.  
  53.            if ( EzDefineDialog( szDlg, "", "", SD_NDLG_REGISTERUSER ) = DLG_ERR) then
  54.                return -1;
  55.            endif;
  56.  
  57.            // Loop in dialog until the user selects a standard button
  58.            bDone = FALSE;
  59.  
  60.            while (!bDone)
  61.  
  62.               nId = WaitOnDialog( szDlg );
  63.  
  64.               switch(nId)
  65.               case DLG_INIT:
  66.                    if( szMsg != "" ) then
  67.                        SdSetStatic( szDlg, SD_STA_MSG, szMsg );
  68.                    endif;
  69.  
  70.                    if( ( svName = "" ) && ( svCompany = "" ) ) then
  71.                        SdGetUserCompanyInfo( svName, svCompany );
  72.                        SdRemoveEndSpace( svName );
  73.                        SdRemoveEndSpace( svCompany );
  74.                    endif;
  75.                    CtrlSetText( szDlg, SD_EDIT_NAME, svName );
  76.                    CtrlSetText( szDlg, SD_EDIT_COMPANY, svCompany );
  77.  
  78.                    hwndDlg = CmdGetHwndDlg( szDlg );
  79.                    SdGeneralInit( szDlg, hwndDlg, STYLE_BOLD, szSdProduct );
  80.  
  81.                    if( szTitle != "" ) then
  82.                        SetWindowText(hwndDlg, szTitle);
  83.                    endif;
  84.  
  85.                    SdRegEnableButton( hwndDlg, NEXT, svName, svCompany );
  86.  
  87.               case SD_EDIT_NAME:
  88.                    nMessage = CtrlGetSubCommand(szDlg);
  89.                    if(nMessage = EDITBOX_CHANGE) then
  90.                         CtrlGetText(szDlg, SD_EDIT_NAME, svName);
  91.                    endif;
  92.  
  93.                    SdRegEnableButton( hwndDlg, NEXT, svName, svCompany );
  94.  
  95.               case SD_EDIT_COMPANY:
  96.                    nMessage = CtrlGetSubCommand(szDlg);
  97.                    if(nMessage = EDITBOX_CHANGE) then
  98.                        CtrlGetText(szDlg, SD_EDIT_COMPANY, svCompany);
  99.                    endif;
  100.  
  101.                    SdRegEnableButton( hwndDlg, NEXT, svName, svCompany );
  102.  
  103.               case SD_PBUT_CONTINUE:
  104.                    nId    = NEXT;
  105.                    bDone  = TRUE;
  106.  
  107.               case BACK:
  108.                    nId    = BACK;
  109.                    bDone  = TRUE;
  110.  
  111.               case BACK:
  112.                    nId    = BACK;
  113.                    bDone  = TRUE;
  114.  
  115.               case DLG_ERR:
  116.                    SdError( -1, "SdRegisterUser" );
  117.                    nId    = -1;
  118.                    bDone  = TRUE;
  119.  
  120.               case DLG_CLOSE:
  121.                    SdCloseDlg( hwndDlg, nId, bDone );
  122.  
  123.               default:
  124.                    // check standard handling
  125.                    if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
  126.                        bDone = TRUE;
  127.                    endif;
  128.               endswitch;
  129.  
  130.            endwhile;
  131.  
  132.            EndDialog( szDlg );
  133.            ReleaseDialog( szDlg );
  134.  
  135.            SdUnInit( );
  136.  
  137.            // record data produced by this dialog
  138.            SdMakeName( szAppKey, szDlg, szTitle, nSdRegisterUser );
  139.            SilentWriteData( szAppKey, "szName", DATA_STRING, svName, 0 );
  140.            SilentWriteData( szAppKey, "szCompany", DATA_STRING, svCompany, 0 );
  141.            SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  142.  
  143.            return nId;
  144.  
  145.        end;
  146.  
  147.  /*------------------------------------------------------------------------*/
  148.  /*                                                                        */
  149.  /*   Function: SdRegEnableButton                                          */
  150.  /*                                                                        */
  151.  /*   Descrip:  This funciton will enable or disable a certain button in   */
  152.  /*             SdRegisterUser dialog.                                     */
  153.  /*   Misc:                                                                */
  154.  /*                                                                        */
  155.  /*------------------------------------------------------------------------*/
  156. function SdRegEnableButton( hwndDlg, nControlID, svName, svCompany )
  157.           HWND  hwndItem;
  158.         begin
  159.  
  160.            hwndItem = GetDlgItem( hwndDlg, nControlID );
  161.            if (!IsWindow( hwndItem)) then return FALSE; endif;
  162.  
  163.            SdRemoveEndSpace( svCompany );
  164.            SdRemoveEndSpace( svName );
  165.  
  166.            if(svName = "" || svCompany = "") then
  167.               EnableWindow( hwndItem, FALSE);
  168.            else
  169.               EnableWindow( hwndItem, TRUE);
  170.            endif;
  171.  
  172.         end;
  173.  
  174.